﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace SuperQuiz.Model
{
    public class QuizResultItem : BindableBase
    {
        private QuizQuestion _Question;
        [IgnoreDataMember]
        public QuizQuestion Question
        {
            get { return this._Question; }
            set { this.SetProperty(ref this._Question, value); }
        }

        [IgnoreDataMember]
        public QuizAnswer MostCorrectAnswer
        {
            get 
            {
                if (MostCorrectAnswerIndex == -1)
                    return null;
                return Question.Answers[MostCorrectAnswerIndex]; 
            }
            set 
            {
                MostCorrectAnswerIndex = Question.Answers.IndexOf(value);
            }
        }

        [IgnoreDataMember]
        public QuizAnswer SelectedAnswer
        {
            get
            {
                if (SelectedAnswerIndex == -1)
                    return null;
                return Question.Answers[SelectedAnswerIndex];
            }
        }

        private int _QuestionIndex;
        public int QuestionIndex
        {
            get { return this._QuestionIndex; }
            set { this.SetProperty(ref this._QuestionIndex, value); }
        }

        private int _MostCorrectAnswerIndex;
        public int MostCorrectAnswerIndex
        {
            get { return this._MostCorrectAnswerIndex; }
            set { this.SetProperty(ref this._MostCorrectAnswerIndex, value); }
        }

        private int _SelectedAnswerIndex;
        public int SelectedAnswerIndex
        {
            get { return this._SelectedAnswerIndex; }
            set { this.SetProperty(ref this._SelectedAnswerIndex, value); }
        }

        private bool _AlternateItem;
        public bool AlternateItem
        {
            get { return this._AlternateItem; }
            set { this.SetProperty(ref this._AlternateItem, value); }
        }
    }
}
